﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp.委托
{
    public class Demo2
    {
        Action<int, int> action = (a1, a2)=>
        {
            int result= a1 + a2;
            Console.WriteLine($"result==Action== {result}");
        };

        Func<int, int, int> myFunc = (a1, a2) =>
        {
            int result = a1 + a2;
            Console.WriteLine($"result==Func== {result}");
            return result; 
        };



        public void Test()
        { 
            action(1, 2); 
            var a= myFunc(1, 2); 
        }

        private void function1(int a, int b) {

            Console.WriteLine($"function1==Action== {a}");
        }

        public void Test2()
        {
            action = function1;

            action(1, 2);
        }


    }
}
